<template>
  <ui-spinner
    v-model="innerValue"
    :placeholder="placeholder"
    :disabled="disabled"
    :width="width"
    :precision="2"
  ></ui-spinner>
</template>
<script>
import { isNumber } from '../../utils/number'

export default {
  name: 'BiMoneyInput',
  props: {
    width: {
      type: String
    },
    value: {
      type: [Number, String]
    },
    disabled: {
      type: Boolean
    },
    placeholder: {
      type: String
    }
  },
  computed: {
    innerValue: {
      get () {
        if (isNumber(this.value)) {
          return Number((this.value / 100).toFixed(2))
        }
        return this.value
      },
      set (val) {
        if (val) {
          val = val * 100
        }
        this.$emit('input', val)
      }
    }
  }
}
</script>
